factorial() {
  if [ "$1" -eq 0 ]; then
    echo 1
  else
    local prev=$(factorial $(($1 - 1)))
    echo $(($1 * prev))
  fi
}
result=$(factorial 5)
echo "The factorial of 5 is $result"
